package com.csjy.migration.hnnd.workflow;

import com.csjy.migration.hnnd.BusinessTool;
import com.csjy.migration.hnnd.DbUtil;
import com.csjy.migration.hnnd.DictTool;
import com.csjy.migration.hnnd.ProgramArgument;
import com.csjy.migration.hnnd.annotation.Task;
import com.csjy.migration.hnnd.business.NdBpmFeeCollectionRecord;
import com.csjy.migration.hnnd.business.SourceBusinessData;
import com.csjy.migration.hnnd.dict.Bank;
import com.csjy.migration.hnnd.dict.RepayType;

import javax.script.ScriptException;
import java.util.Map;



/*
服务性代偿用款(item-sencor-loan-qiao-hny)
phs*/

public class ItemSencorLoanQiaoHny extends WorkflowMigration{
    private NdBpmFeeCollectionRecord ndBpmFeeCollectionRecord = null;

    public ItemSencorLoanQiaoHny(DbUtil sourceDbUtil, DbUtil targetDbUtil, SourceBusinessData sourceData, ProgramArgument programArgument, String projectId, String procInstId, Map procInstRow) throws Exception {
        super(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId, procInstRow);
        this.customInitData();
    }

    @Override
    public void customInitData() throws Exception {
        this.curBizType = "fwxdcyk";
        this.ndBpmFeeCollectionRecord = new NdBpmFeeCollectionRecord(sourceDbUtil,targetDbUtil,sourceData,programArgument,projectId,procInstId);

    }

    @Override
    public void customInsertOrUpdateData() throws Exception {
        ndBpmFeeCollectionRecord.start();
    }


    @Task("服务性代偿用款@法务部经办人提交申请")
    public void fwxfwbjbrtjsq() throws Exception {

        this.curCustomData.put("creditMoney",this.getJbpmVarInstValueByName("transacAssureSum"));
        this.curCustomData.put("coverageMoney",this.getJbpmVarInstValueByName("askDeferSum"));
        this.curCustomData.put("bank",DictTool.getTargetDictCode(Bank.class,this.getJbpmVarInstValueByName("promBank")));
        this.curCustomData.put("bankName",this.getJbpmVarInstValueByName("bankBranchName"));
        this.curCustomData.put("payDate",this.getJbpmVarInstValueByName("promContBtime"));
        this.curCustomData.put("endDate",this.getJbpmVarInstValueByName("promContEtime"));
        this.curCustomData.put("creditFile",this.getJbpmVarInstValueByName("loanContractNo"));
        this.curCustomData.put("payMoney",this.getJbpmVarInstValueByName("thisAskUseSum"));
        this.curCustomData.put("customBank",this.getJbpmVarInstValueByName("clientBankId"));
        this.curCustomData.put("payAccountNo",this.getJbpmVarInstValueByName("clientBankAccount"));
        // 客户还款方式(新老系统字典内容完全不一样)
        this.curCustomData.put("repayType",sourceData.getRepayType());
        // 还款计划
        this.curCustomData.put("repaymentPlanHy","还款方式："+BusinessTool.getOldDictDataNameByDictCodeAndDataCode("35",this.getJbpmVarInstValueByName("returnWay"))
            +" 还款计划："+ BusinessTool.getOldDictDataNameByDictCodeAndDataCode("46",this.getJbpmVarInstValueByName("planFlag")));
        this.curCustomData.put("everyAverageMoney","还款方式："+ BusinessTool.getOldDictDataNameByDictCodeAndDataCode("35",this.getJbpmVarInstValueByName("returnWay"))
            +" 还款计划："+ BusinessTool.getOldDictDataNameByDictCodeAndDataCode("46",this.getJbpmVarInstValueByName("planFlag")));
        // 出保银行 promBank
        this.curCustomData.put("jwframe_promBank", DictTool.getTargetDictCode(Bank.class,this.getJbpmVarInstValueByName("promBank")));
        // 客户开户银行 clientBankId
        this.curCustomData.put("jwframe_clientBankId", DictTool.getTargetDictCode(Bank.class,this.getJbpmVarInstValueByName("clientBankId")));
        // 担保项目品种 assureClass
        this.curCustomData.put("jwframe_assureClassName", BusinessTool.getOldDictDataNameByDictCodeAndDataCode("12",this.getJbpmVarInstValueByName("assureClass")));
        // 还款计划 planFlag
        this.curCustomData.put("jwframe_planFlagName", this.getJbpmVarInstValueByName("planFlag"));
        this.curCustomData.put("jwframe_planFlagName", BusinessTool.getOldDictDataNameByDictCodeAndDataCode("46",this.getJbpmVarInstValueByName("planFlag")));

        this.curModelMap.put("all", new String[]{"task1563518245991xyb","下一步"});
        this.curAffixTypeCommon = "fwxdcyk";
        this.setCommonData(true,null);
        this.ndBpmFeeCollectionRecord.getTaskParamMap().put(this.curJbpmTaskInstanceId,  this.initTaskParamMap());
    }
    @Task("服务性代偿用款@法务部经理业务副总审核")
    public void fwxfwbjlywfzsh() throws Exception {
        this.curModelMap.put("通过", new String[]{"task1563518292566xyb","下一步"});

        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@总经理审核签字")
    public void fwxzjlshqz() throws Exception {
        this.curModelMap.put("提交投票", new String[]{"task1563518352984tjtp","提交投票"});
        this.curModelMap.put("不通过", new String[]{"endbtg","不通过"});
        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@评审委员投票表决")
    public void fwxpswytpbj() throws Exception {

        String voteResult = this.getJbpmVarInstValueByName("voteResult");
        if(voteResult == null){
            this.curCustomData.put("voting_results", "1");
        } else {
            Integer voteResultInt = Integer.parseInt(voteResult+1);
            this.curCustomData.put("voting_results",voteResultInt);
        }
        this.curCustomData.put("rating_description",this.getJbpmVarInstValueByName("remark"));

        this.curModelMap.put("all", new String[]{"task1563518409637tj","提交"});
        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@评审会主任签字")
    public void fwxpshzrqz() throws Exception {

        this.curCustomData.put("payMoney",this.getJbpmVarInstValueByName("thisAskUseSum_1"));
        this.curModelMap.put("通过", new String[]{"task1563518572356tg","通过"});
        this.curModelMap.put("不通过", new String[]{"endbtg","不通过"});
        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@法务部经办人确认签协议")
    public void fwxfwbjbrqrqxy() throws Exception {

        this.curCustomData.put("creditFile",this.getJbpmVarInstValueByName("sloanContractNo"));
        this.curModelMap.put("已签协议", new String[]{"task1563518624229yqxy","已签协议"});
        this.curModelMap.put("未签协议", new String[]{"endwqxy","未签协议"});
        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@出纳确认收取资金占用费")
    public void fwxcnqrsqzjzyf() throws Exception {
        this.curModelMap.put("all", new String[]{"task1563518684108xyb","下一步"});
        this.curCustomData.put("assFareWay",this.getJbpmVarInstValueByName("assFareWay"));
        this.setCommonData(true,null);
        this.ndBpmFeeCollectionRecord.getTaskParamMap().put(this.curJbpmTaskInstanceId,  this.initTaskParamMap());
    }
    @Task("服务性代偿用款@财务部门经理审核")
    public void fwxcwbmjlsh() throws Exception {

        this.curModelMap.put("通过", new String[]{"task1563518730235tg","通过"});
        this.curModelMap.put("不通过", new String[]{"endbty","不同意"});
        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@财务副总审批")
    public void fwxcwfzsp() throws Exception {

        this.curModelMap.put("通过", new String[]{"task1563519585058tg","通过"});
        this.curModelMap.put("不同意", new String[]{"endbty","不同意"});
        this.setCommonData(true,null);
    }
    @Task("服务性代偿用款@出纳确认支付代偿资金")
    public void fwxcnqrzfdczj() throws Exception {

        this.curCustomData.put("virtualPayMoney",this.getJbpmVarInstValueByName("sureAskUseSum"));
        this.curCustomData.put("annualInterestRate",this.getJbpmVarInstValueByName("monthRate"));
        this.curCustomData.put("payDate",this.getJbpmVarInstValueByName("accountBtime"));
        this.curCustomData.put("endDate",this.getJbpmVarInstValueByName("accountEtime"));
        this.curCustomData.put("bank", DictTool.getTargetDictCode(Bank.class,this.getJbpmVarInstValueByName("exPromBank")));
        this.curCustomData.put("bankName",this.getJbpmVarInstValueByName("exBankBranchName"));
        this.curAffixType = "zfpz";
        this.curModelMap.put("all", new String[]{"endtg","通过"});
        this.setCommonData(true,null);
    }
    @Task("主动代偿用款@法务部经办人提交申请")
    public void zdfwbjbrtjsq() throws Exception, ScriptException {
        fwxfwbjbrtjsq();

    }
    @Task("主动代偿用款@财务经办人提交申请")
    public void zdcwjbrtjsq() throws Exception, ScriptException {
        fwxfwbjbrtjsq();

    }
    @Task("主动代偿用款@法务部经理业务副总审核")
    public void zdfwbjlywfzsh() throws Exception {

        fwxfwbjlywfzsh();

    }
    @Task("主动代偿用款@法务部经办人确认签协议")
    public void zdfwbjbrqrqxy() throws Exception {


        fwxfwbjbrqrqxy();
    }
    @Task("主动代偿用款@总经理审核签字")
    public void zjlshqz() throws Exception {


        this.setCommonData(true,null);
    }
    @Task("主动代偿用款@评审委员投票表决")
    public void zdpswytpbj() throws Exception {


        this.setCommonData(true,null);
    }
    @Task("主动代偿用款@评审会主任签字")
    public void zdpshzrqz() throws Exception {


        this.setCommonData(true,null);
    }
    @Task("主动代偿用款@出纳确认收取资金占用费")
    public void zdcnqrsqzjzyf() throws Exception, ScriptException {

        fwxcnqrsqzjzyf();

    }
    @Task("主动代偿用款@财务部门经理审核")
    public void adcwbmjlsh() throws Exception {


        fwxcwbmjlsh();
    }
    @Task("主动代偿用款@财务副总审批")
    public void zdcwfzsp() throws Exception {

        fwxcwfzsp();

    }
    @Task("主动代偿用款@出纳确认支付代偿资金")
    public void zdcnqrzfdczj() throws Exception {


        fwxcnqrzfdczj();
    }

}
